import java.sql.SQLOutput;
import java.util.Scanner;
import java.util.Random;

public class logic_control {
    public static void main1(String[] args) {
        //if练习
        //判断输入成绩的等级
//        Scanner scanner = new Scanner(System.in);
//        //循环控制多次输入，ctrl+d控制结束
//        while(scanner.hasNextInt()) {
//            int score = scanner.nextInt();
//            if ((score >= 90) && (score <= 100)) {
//                System.out.println("等级A");
//            } else if ((score >= 80) && (score < 90)) {
//                System.out.println("等级B");
//            } else if ((score >= 70) && (score < 80)) {
//                System.out.println("等级C");
//            } else if ((score >= 60) && (score < 70)) {
//                System.out.println("等级D");
//            } else if ((score >= 0) && (score < 60)) {
//                System.out.println("等级E");
//            } else {
//                System.out.println("输入错误,请输入0-100之间的分数");
//            }
//        }
        //闰年判断
        Scanner scanner1 = new Scanner(System.in);
        while (scanner1.hasNextInt()) {
            int year = scanner1.nextInt();
            if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0)) {
                System.out.println("闰年");
            } else {
                System.out.println("不是闰年");
            }

        }
    }

    public static void main2(String[] args) {
        //switch练习
        Scanner scanner1 = new Scanner(System.in);
        while (scanner1.hasNextInt()) {
            int day = scanner1.nextInt();
            //注意switch判断表达式的值必须为byte、char、short、int或引用类型：String常量串、枚举类型
            switch (day) {
                case 1:
                    System.out.println("星期一");
                    break;
                case 2:
                    System.out.println("星期二");
                    break;
                case 3:
                    System.out.println("星期三");
                    break;
                case 4:
                    System.out.println("星期四");
                    break;
                case 5:
                    System.out.println("星期五");
                    break;
                case 6:
                    System.out.println("星期六");
                    break;
                case 7:
                    System.out.println("星期天");
                    break;
                default:
                    System.out.println("输入错误");
                    break;
            }

        }
    }

    public static void main3(String[] args) {
        //循环练习
        //while
        //1!+2!+...+n!
//        int a = 1;
//        int sum = 0;
//        Scanner scanner = new Scanner(System.in);
//        int n = scanner.nextInt();
//        while(a <= n){
//            int result1 = 1;
//            int temp = 1;
//            while(temp <= a ){
//                result1 *= temp;
//                temp++;
//            }
//            sum += result1;
//            a++;
//        }
//        System.out.println(sum);

        //100-200找到第一个3和所有3的倍数(break和continue的区别)
//        int num = 100;
//        while (num <= 200) {
//            if (num % 3 == 0) {
//                System.out.println("找到了 3 的倍数, 为:" + num);
//                break;
//            }
//            num++;
//        }

//        int num = 100;
//        while (num <= 200) {
//            if (num % 3 != 0) {
//                num++; // 这里的 ++ 不要忘记! 否则会死循环.
//                continue;
//            }
//            System.out.println("找到了 3 的倍数, 为:" + num);
//            num++;
//        }
    }

    public static void main4(String[] args) {
        //for
        //1!+2!+...+n!
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int sum = 0;
        for (int i = 1; i <= n; i++) {
            int tmp = 1;
            for (int j = 1; j <= i; j++) {
                tmp *= j;
            }
            sum += tmp;
        }
        System.out.println("sum = " + sum);
    }

    public static void main5(String[] args) {
        //输入输出
//        Scanner sc = new Scanner(System.in);
//        System.out.println("请输入你的姓名：");
//        String name = sc.nextLine();
//        System.out.println("请输入你的年龄：");
//        int age = sc.nextInt();
//        System.out.println("请输入你的工资：");
//        float salary = sc.nextFloat();
//        System.out.println("你的信息如下：");
//        System.out.println("姓名: "+name+"\n"+"年龄："+age+"\n"+"工资："+salary);
//        sc.close(); //要记得调用关闭方法
        //循环输入多个数求平均值，通过ctrl+d(idea)终止输入cmd(cmd)
        Scanner sc = new Scanner(System.in);
        int sum = 0;
        int num = 0;
        while (sc.hasNextInt()) {
            int tmp = sc.nextInt();
            sum += tmp;
            num++;
        }
        System.out.println("sum = " + sum);
        System.out.println("avg = " + sum / num);
        sc.close();
    }

    public static void main(String[] args) {
        //用户登录+猜数字游戏
        String user = "admin";
        String password = "123456";
        Scanner scanner = new Scanner(System.in);
        Scanner scanner1 = new Scanner(System.in);
        int n = 3;
        while(n!=0){
            System.out.println("请输入用户名:");
            String user1 = scanner.nextLine();
            System.out.println(user1);
            System.out.println("请输入密码:");
            String password1 = scanner.nextLine();
            System.out.println(password1);
            if((user1.equals(user))&&(password1.equals(password))){//字符串比较用equals方法
                System.out.println("登录成功");
                Random random = new Random();
                int num = random.nextInt(100);
                while(true) {
                    System.out.println("请输入1-100之间的一个数字");
                    int num1 = scanner1.nextInt();
                    if (num1 == num) {
                        System.out.println("恭喜你猜对了！");
                        break;
                    } else if (num1 <= num) {
                        System.out.println("猜小了");
                    } else {
                        System.out.println("猜大了");
                    }
                }
                break;
            }
            else{
                n--;
                System.out.printf("用户名或密码错误,还剩%d次输入机会\n", n);
                continue;
            }
        }
        scanner.close();
        scanner1.close();
    }

}